find the maximum and minimum value of an array